import { createApp } from 'vue'
import App from '@/App.vue'
import { setupRouter } from '@/router/index'
import { createPinia } from 'pinia'
import { createNotivue } from 'notivue'
import { useUserStore } from './store/user'
import { initLocalForage } from './store/db'

import 'notivue/notification.css' // Only needed if using built-in <Notification />
import 'notivue/animations.css' // Only needed if using default animations
import '@/style/tailwind.css'
import '@/style/style.css'
import 'ant-design-vue/dist/reset.css'
import 'video.js/dist/video-js.css'

const setupApp = async () => {
	const app = createApp(App)
	const pinia = createPinia()
	const notivue = createNotivue({
		enqueue: false,
		limit: 5,
		position: 'bottom-right',
		notifications: {
			global: {
				duration: 3200,
			},
		},
	})
	app.use(pinia)
	app.use(notivue)
	const userStore = useUserStore()
	userStore.loadFromLocalStorage()
	initLocalForage()
	setupRouter(app)
	app.mount('#app')
}
setupApp()
